<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>使用length调整大小或清空数组</title>
</head>

<body>

</body>
<script>
  "use strict"; {
    let entries = [1, 2, 3, 4, 5, 6, 7];
    console.log(entries.length);
    // 7
    entries.length = 4;
    console.log(entries.length);
    // 4
    console.log(entries);
    { //清空数组
      let entries = [1, 2, 3, 4, 5, 6, 7];
      console.log(entries.length);
      // 7
      entries.length = 0;
      console.log(entries.length);
      // 0
      console.log(entries);
      // []
    };
  };
</script>

</html>